home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / news / inn1.000 / inn1.4sec-linux-src.tar / inn / BUILD next >
Text File  |  1993-03-18  |  7KB  |  294 lines

  1. #! /bin/sh
  2. ##  $Revision: 1.9 $
  3. ##  An interactive script to configure, build, and install InterNetNews.
  4. ##  Installation documentation can be found in the "Install.ms*" files;
  5. ##  please see the README!
  6.  
  7. UMASK=${INN_UMASK-027}
  8.  
  9. if [ ! -f config/config.data ] ; then
  10.     X=`basename ${EDITOR-vi}`
  11.     echo "You don't have a config.data file.  Do the following:" 1>&2
  12.     echo '    cd config' 1>&2
  13.     echo '    cp config.dist config.data' 1>&2
  14.     echo "    $X config.data" 1>&2
  15.     echo '    cd ..' 1>&2
  16.     echo 'And start again.' 1>&2
  17.     exit 1
  18. fi
  19.  
  20. echo 'NOTE:  If you just type [RETURN] to any question, this script will'
  21. echo '       assume you are being cautious, and default to whatever answer'
  22. echo '       is "safer."  This usually means recompiling.'
  23. echo ''
  24. echo '       You cannot install over a running system; this script will'
  25. echo '       remind you about this later.'
  26.  
  27. echo ''
  28. if [ -f config/subst ] ; then
  29.     if cmp -s config/subst config/subst.sh ; then
  30.     TYPE="sh"
  31.     else
  32.     TYPE="c"
  33.     fi
  34.     echo "A ${TYPE} version of subst exists;"
  35.     file config/subst
  36.     echo '-- do you want to use it [y or n]?  ' | tr -d '\012'
  37.     read reply
  38.     reply=`echo "${reply}" | tr -d ' \011'`
  39.     case "X${reply}" in
  40.     X[yY]*)
  41.     ;;
  42.     *)
  43.     rm config/subst
  44.     if [ -f config/subst ] ; then
  45.         echo 'Please remove config/subst and start again.' 1>&2
  46.         exit 1
  47.     fi
  48.     ;;
  49.     esac
  50. fi
  51.  
  52. if [ ! -f config/subst ] ; then
  53.     echo ''
  54.     echo 'Use the /bin/sh version of subst, or the C version?'
  55.     echo "Type sh, c, or x if you don't care:  " | tr -d '\012'
  56.     read style
  57.     reply=`echo "${reply}" | tr -d ' \011'`
  58.     case "X${style}" in
  59.     X[Cc]*)    WHAT=c        ;;
  60.     X[Ss][Hh]*)    WHAT=sh        ;;
  61.     *)        WHAT=subst    ;;
  62.     esac
  63.  
  64.     echo 'Building subst...'
  65.     cd config ; make ${WHAT} ; cd ..
  66.     if [ ! -f config/subst ] ; then
  67.     echo "Can't build subst -- please investigate and fix." 1>&2
  68.     exit 1
  69.     fi
  70. fi
  71.  
  72. echo ''
  73. echo 'Have you already built the executables [y or n]?  ' | tr -d '\012'
  74. read reply
  75. reply=`echo "${reply}" | tr -d ' \011'`
  76. case "X${reply}" in
  77. X[yY]*)
  78.     MUSTBUILD=false
  79.     ;;
  80. *)
  81.     MUSTBUILD=true
  82.     ;;
  83. esac
  84.  
  85. if ${MUSTBUILD} ; then
  86.     echo ''
  87.     echo 'Configuring INN'
  88.     cd config ; make quiet ; cd ..
  89.  
  90.     echo ''
  91.     echo 'Building and linting the INN library.'
  92.     echo 'Please examine the lint output.'
  93.     cd lib ; make lint ; cd ..
  94.     ${PAGER-more} lib/lint || cat lib/lint
  95.  
  96.     echo ''
  97.     echo 'Continue with the build [y or n]?  ' | tr -d '\012'
  98.     read reply
  99.     reply=`echo "${reply}" | tr -d ' \011'`
  100.     case "X${reply}" in
  101.     X[yY]*)
  102.     ;;
  103.     *)
  104.     echo 'Fix any problems and start again.' 1>&2
  105.     exit 1
  106.     ;;
  107.     esac
  108.  
  109.     echo ''
  110.     echo 'Run lint after each compile [y or n]?  ' | tr -d '\012'
  111.     read reply
  112.     reply=`echo "${reply}" | tr -d ' \011'`
  113.     case "X${reply}" in
  114.     X[yY]*)
  115.     WHAT=lint
  116.     echo ''
  117.     echo 'Compiling and linting the INN programs.'
  118.     ;;
  119.     *)
  120.     WHAT=all
  121.     echo ''
  122.     echo 'Compiling the INN programs.'
  123.     ;;
  124.     esac
  125.     make ${WHAT} || {
  126.     echo 'Could not build INN.  Fix any problems and start again.' 1>&2
  127.     exit 1
  128.     }
  129.  
  130.     if [ ${WHAT} = lint ] ; then
  131.     echo ''
  132.     echo 'Do you want to see the lint output [y or n]?  ' | tr -d '\012'
  133.     read reply
  134.     reply=`echo "${reply}" | tr -d ' \011'`
  135.     case "X${reply}" in
  136.     X[yY]*)
  137.         ${PAGER-more} */lint || cat */lint
  138.         ;;
  139.     esac
  140.     fi
  141. fi
  142.  
  143. umask ${UMASK}
  144. echo ''
  145. echo 'Setting umask to' `umask`
  146.  
  147. echo ''
  148. echo 'Do the spool, etc., directories exist [y or n]?  ' | tr -d '\012'
  149. read reply
  150. reply=`echo "${reply}" | tr -d ' \011'`
  151. case "X${reply}" in
  152. X[nN]*)
  153.     echo 'Please su to root and run the "makedirs.sh" script'
  154.     su
  155.     ;;
  156. esac
  157.  
  158. echo ''
  159. echo 'You are now ready to install the INN programs and config files.'
  160. echo 'You CANNOT DO THIS if INN is running now -- you must shut down'
  161. echo 'your news system first.'
  162. echo 'Do you want to continue with the installation [y or n]?  ' | tr -d '\012'
  163. read reply
  164. reply=`echo "${reply}" | tr -d ' \011'`
  165. case "X${reply}" in
  166. X[yY]*)
  167.     ;;
  168. *)
  169.     echo 'Fix any problems and start again.' 1>&2
  170.     exit 1
  171. esac
  172.  
  173. echo ''
  174. echo 'Installing the INN programs.'
  175. echo 'Part of this may fail if you do not have have write permission in'
  176. echo 'all the destination directories.  This is often the case for innd'
  177. echo 'and inndstart, for example.  If the following "make" fails, do this:'
  178. echo '    echo make update | su'
  179. echo 'and rerun this script.'
  180. make update || {
  181.     echo 'Could not install INN.  Fix any problems and start again.' 1>&2
  182.     exit 1
  183. }
  184.  
  185. echo ''
  186. echo 'Building the data files.'
  187. cd site
  188. make all || {
  189.     echo 'Fix any problems and start again.' 1>&2
  190.     exit 1
  191. }
  192. cd ..
  193.  
  194. MORETODO=true
  195. SUB='a subshell'
  196. while ${MORETODO} ; do
  197.     echo ''
  198.     echo "Start ${SUB} to edit the config files [y or n]?  " | tr -d '\012'
  199.     read reply
  200.     reply=`echo "${reply}" | tr -d ' \011'`
  201.     case "X${reply}" in
  202.     X[yY]*)
  203.     cd site
  204.     ${SHELL-/bin/sh}
  205.     cd ..
  206.     SUB='another shell'
  207.     ;;
  208.     X[nN]*)
  209.     MORETODO=false
  210.     ;;
  211.     esac
  212. done
  213.  
  214. echo ''
  215. echo 'Installing the data files.'
  216. cd site
  217. make install || {
  218.     echo 'Could not install INN.  Fix any problems and start again.' 1>&2
  219.     exit 1
  220. }
  221. cd ..
  222.  
  223. echo ''
  224. echo 'Checking other data files.'
  225. TEMP=${TMPDIR-/tmp}/inn$$
  226. cat >${TEMP} <<\EOF
  227. # =()<ACTIVEFILE=@<_PATH_ACTIVE>@>()=
  228. ACTIVEFILE=/usr/lib/news/active
  229. # =()<HISTORY=@<_PATH_HISTORY>@>()=
  230. HISTORY=/usr/lib/news/history
  231. # =()<NEWSBIN=@<_PATH_NEWSBIN>@>()=
  232. NEWSBIN=/usr/lib/newsbin
  233. # =()<NEWSLIB=@<_PATH_NEWSLIB>@>()=
  234. NEWSLIB=/usr/lib/news
  235. # =()<OWNERS="-o @<NEWSUSER>@ -g @<NEWSGROUP>@">()=
  236. OWNERS="-o news -g news"
  237. EOF
  238. ./config/subst -f config/config.data ${TEMP} >/dev/null
  239. . ${TEMP}
  240. rm ${TEMP}
  241. PATH=${PATH}:${NEWSBIN} ; export PATH
  242.  
  243. ##  Active file.
  244. if [ ! -f ${ACTIVEFILE} ] ; then
  245.     echo ''
  246.     echo 'You have no active file; making one.'
  247.     echo 'Make sure to create the new groups you want!'
  248.     echo 'control 0000000000 0000000001 y' >${ACTIVEFILE}
  249.     echo 'junk 0000000000 0000000001 y' >>${ACTIVEFILE}
  250. fi
  251.  
  252. ##  History file.
  253. if [ ! -f ${HISTORY} ] ; then
  254.     touch ${HISTORY}
  255.     FLAGS="-r -i"
  256. else
  257.     echo ''
  258.     echo 'Did you use DBZ in your old news system [y or n]?  ' | tr -d '\012'
  259.     read reply
  260.     reply=`echo "${reply}" | tr -d ' \011'`
  261.     case "X${reply}" in
  262.     X[yY]*)
  263.     ;;
  264.     *)
  265.     FLAGS="-i"
  266.     echo 'Will rebuild full history file'
  267.     cp /dev/null ${HISTORY}
  268.     ;;
  269.     esac
  270. fi
  271.  
  272. echo ''
  273. echo 'Setting correct ownership of history file -- double-check when done.'
  274. sh ./installit.sh ${OWNERS} -m 0664 ${HISTORY} ${HISTORY}
  275.  
  276. echo ''
  277. echo 'Rebuilding history.  This may take some time, so it is the last thing'
  278. echo 'in the installation.'
  279. HERE=`/bin/pwd`
  280. HISTORYDIR=`echo ${HISTORY} | sed -e 's@\(.*\)/.*@\1@'`
  281. cd ${HISTORYDIR}
  282. ${NEWSBIN}/makehistory ${FLAGS} || {
  283.     echo 'Could not build history.' 1>&2
  284.     echo "Please run ${NEWSBIN}/makehistory by hand." 1>&2
  285.     exit 1
  286. }
  287. mv history.n.dir history.dir
  288. mv history.n.pag history.pag
  289. cd ${HERE}
  290. sh ./installit.sh ${OWNERS} -m 0664 ${HISTORY}.dir ${HISTORY}.dir
  291. sh ./installit.sh ${OWNERS} -m 0664 ${HISTORY}.pag ${HISTORY}.pag
  292.  
  293. exit 0
  294.